package com.nbjtjc.safe.mapper.sys;

import com.nbjtjc.safe.bean.Page;
import com.nbjtjc.safe.model.sys.SysNotice;
import com.nbjtjc.util.MyMapper;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface SysNoticeMapper extends MyMapper<SysNotice> {

    List<SysNotice> search(@Param("notice") SysNotice sysNotice,@Param("page") Page page
    ,@Param("noticeIds") List<Integer> noticeIds);
    @ResultMap("BaseResultMap")
    @Select("select * from sys_notice where id_type=1 and relate_id =#{relatedId}")
    SysNotice findByPlanPublicId(@Param("relatedId") int relatedId);
    @ResultMap("BaseResultMap")
    @Select("select * from sys_notice where id_type=2 and relate_id =#{relatedId}")
    SysNotice findPlanPublicRelieveNotice(@Param("relatedId") int relatedId);
    @Delete("delete from sys_notice where id_type=2 and relate_id =#{relatedId} ")
    int deletePlanPublicRelieveNotice(@Param("relatedId") int relatedId);
    @Select("select max(id) from sys_notice where id_type=1 and relate_id=#{emgPlanPublicId}")
    Integer findLatestSysNoticeIdByPlanPublicId(@Param("emgPlanPublicId") int emgPlanPublicId);
    @Update("update sys_notice set status=1 where relate_id=#{planPublicId} and id_type=#{idType}")
    int updateNoticeTarget(@Param("planPublicId") int emgPlanPublicId,@Param("idType") int idType);
}